<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_scheme" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="gotoPage('/mes/product/TechnologyStatistical?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <el-button @click="popAddTestPlan('')" type='success' size="mini"><i class='fa fa-plus'></i>增加检测方案</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 检测方案 </span>
      </div>
      <el-table :data="s_scheme">
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="popUpTestPlan1('&CMIDscheme_id='+scope.row.scheme_id+'')">修改</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="d_scheme('&CMID4='+scope.row.scheme_id+'')">删除</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="检测方案名称" prop="scheme_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/mes/product/PlanDet?CMIDscheme_id='+scope.row.scheme_id+''+vueparams+'')" type='primary'>{{scope.row.scheme_name}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="编制人" prop="contact_name">
        </el-table-column>
        <el-table-column label="编制时间" prop="entered">
          <template slot-scope="scope">
            {{getDateTimeString(scope.row,'entered')}}
          </template>
        </el-table-column>
        <el-table-column label="状态" prop="scheme_state">
          <template slot-scope="scope">
            {{getValueName("启用=1,未启用=0",scope.row.scheme_state)}}
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <el-dialog :visible.sync="AddTestPlanVisible" append-to-body>
      <AddTestPlan v-if="AddTestPlanVisible" ref="AddTestPlan" :popparams="popparams"> </AddTestPlan>
    </el-dialog>
    <el-dialog :visible.sync="UpTestPlan1Visible" append-to-body>
      <UpTestPlan1 v-if="UpTestPlan1Visible" ref="UpTestPlan1" :popparams="popparams"> </UpTestPlan1>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import AddTestPlan from "@/views/mes/product/AddTestPlan";
  import UpTestPlan1 from "@/views/mes/product/UpTestPlan1";
  export default {
    name: 'TestPlanList',
    components: {
      AddTestPlan,
      UpTestPlan1,
    },
    props: ['popparams'],
    data() {
      return {
        AddTestPlanVisible: false,
        AddTestPlanValue: null,
        AddTestPlanDesc: null,
        UpTestPlan1Visible: false,
        UpTestPlan1Value: null,
        UpTestPlan1Desc: null,
        vueparams: this.getVUEParams(""),
        s_scheme: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/testPlanList?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_scheme(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/d_scheme?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popAddTestPlan(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.AddTestPlanVisible = !this.AddTestPlanVisible;
      },
      popUpTestPlan1(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.UpTestPlan1Visible = !this.UpTestPlan1Visible;
      },
    },
  }
</script>
